module ApplicationHelper 

    def sortable(column, title = nil)
        title ||= column.titleize
        css_class = (column == sort_column) ? "current #{sort_direction}" : nil
        title += css_class.nil? ? "" : ((column == sort_column && sort_direction == "asc") ? " <i class='icon-caret-up'></i>" : " <i class='icon-caret-down'></i>")
        direction = (column == sort_column && sort_direction == "asc") ? "desc" : "asc"
        link_to raw(title), {:sort => column, :direction => direction}, {:class => css_class , remote: true }
    end

    def hotel_star(star)
      if star == "0"
        result = 'a'
      elsif star == "1"
        result = 'b'
      elsif star == "2"
        result = 'c'
      elsif star == "3"
        result = 'd'
      elsif star == "4"
        result = 'e'
      elsif star == "6"
        result = 'f'
      end  
      result 
    end

    def user_rating(rating)
      rating = (rating.to_i / 2).to_s
      if rating == "0"
        result = 'a'
      elsif rating == "1"
        result = 'b'
      elsif rating == "2"
        result = 'c'
      elsif rating == "3"
        result = 'd'
      elsif rating == "4"
        result = 'e'
      elsif rating == "6"
        result = 'f'
      end  
      result 
    end
end
